let json = [
  {
    id: 1,
    name: '张三',
    age: 18,
    school: {
      name: '北京大学',
      address: '北京市海淀区'
    }
  },
  {
    id: 2,
    name: '李四',
    age: 19,
    school: {
      name: '清华大学',
      address: '北京市海淀区'
    }
  },
  {
    id: 3,
    name: '王五',
    age: 20,
    school: {
      name: '复旦大学',
      address: '上海市杨浦区'
    }
  }
]
let name = '张三'
let age = 18

// 美化打印实现方法
const prettyLog = () => {
  const isEmpty = (value) => {
    return value == null || value === undefined || value === '';
  };
  const prettyPrint = (title, text, color) => {
    console.log(
      `%c ${title} %c ${text} %c`,
      `background:${color};border:1px solid ${color}; padding: 1px; border-radius: 2px 0 0 2px; color: #fff;`,
      `border:1px solid ${color}; padding: 1px; border-radius: 0 2px 2px 0; color: ${color};`,
      'background:transparent'
    );
  };
  const info = (textOrTitle, content = '') => {
    const title = isEmpty(content) ? 'Info' : textOrTitle;
    const text = isEmpty(content) ? textOrTitle : content;
    prettyPrint(title, text, '#909399');
  };
  const error = (textOrTitle, content = '') => {
    const title = isEmpty(content) ? 'Error' : textOrTitle;
    const text = isEmpty(content) ? textOrTitle : content;
    prettyPrint(title, text, '#F56C6C');
  };
  const warning = (textOrTitle, content = '') => {
    const title = isEmpty(content) ? 'Warning' : textOrTitle;
    const text = isEmpty(content) ? textOrTitle : content;
    prettyPrint(title, text, '#E6A23C');
  };
  const success = (textOrTitle, content = '') => {
    const title = isEmpty(content) ? 'Success ' : textOrTitle;
    const text = isEmpty(content) ? textOrTitle : content;
    prettyPrint(title, text, '#67C23A');
  };
  return {
    info,
    error,
    warning,
    success
  };
};
// 创建打印对象
const log = prettyLog();

log.warning('一级警告', '啊啊啊啊啊啊 ');

log.success('设置成功', '嘿嘿嘿嘿嘿 ');
console.table(json) 


// 将嵌套结构扁平化
let flattenedData = json.map(item => ({
  id: item.id,
  name: item.name,
  age: item.age,
  'school.name': item.school.name,
  'school.address': item.school.address
}));

// 在控制台中展示为表格
console.table(flattenedData);